<template>
	<view class="container">
		<!-- 没登录的时候 -->
		<u-grid :border="true" v-if="!auth || JSON.stringify(auth) == '{}'" col="2" @click="login" align="center"
			:customStyle="GridStyle">
			<!-- customStyle自定义样式语法 -->
			<u-grid-item :customStyle="ItemStyle" v-if="auth.id==1">
				<u-icon :customStyle="IconStyle" color="#19BC9C" size="40" name="account-fill" />
				<text>管理员管理</text>
			</u-grid-item>

			<u-grid-item :customStyle="ItemStyle">
				<u-icon :customStyle="IconStyle" color="#19BC9C" size="40" name="coupon-fill" />
				<text>管理员日志</text>
			</u-grid-item>

			<!-- 
			<u-grid-item :customStyle="ItemStyle">
				<u-icon :customStyle="IconStyle" color="#19BC9C" size="40" name="bag" />
				<text>角色组</text>
			</u-grid-item>	 -->

			<!-- <u-grid-item :customStyle="ItemStyle">
				<u-icon :customStyle="IconStyle" color="#19BC9C" size="40" name="man-add" />
				<text>菜单规则</text>
			</u-grid-item> -->



		</u-grid>
		<!-- 有登录的时候 -->
		<u-grid :border="true" v-else col="2" align="center" :customStyle="GridStyle">
			<u-grid-item :customStyle="ItemStyle" @click="toemployee">
				<u-icon :customStyle="IconStyle" color="#008dfb" size="40" name="account" />
				<text>管理员管理</text>
			</u-grid-item>

			<u-grid-item :customStyle="ItemStyle" @click="adminlog">
				<u-icon :customStyle="IconStyle" color="#e83e58" size="40" name="level" />
				<text>管理员日志</text>
			</u-grid-item>
			
			<!-- 
			<u-grid-item :customStyle="ItemStyle" @click="torole">
				<u-icon :customStyle="IconStyle" color="#f6b80d" size="40" name="lock-opened-fill" />
				<text>角色组</text>
			</u-grid-item>	 -->

			<!-- <u-grid-item :customStyle="ItemStyle">
				<u-icon :customStyle="IconStyle" color="#3a3c55" size="40" name="grid-fill" />
				<text>菜单规则</text>
			</u-grid-item> --> 

		</u-grid>
		<u-toast ref="notice"></u-toast>
	</view>
</template>

<script>
export default {
	onLoad() {
		this.auth = uni.getStorageSync('auth') ? uni.getStorageSync('auth') : {}
		this.qxrouter = uni.getStorageSync('qxrouter')

		if (!this.qxrouter || JSON.stringify(this.qxrouter) == "{}")//如果auth为空不存在并且auth对象为空对象
		{
			this.qxrouter = qxrouter

		}
	},
	created() {

		this.timer = setInterval(() => {

			let a = this.$u.count.check()
			console.log(a)

		}, 15000);

	},
	beforeDestroy() {
		clearInterval(this.timer)
	},
	data() {
		return {
			qxrouter: {},
			GridStyle: {
				borderBottom: '1px solid #dadbde'
			},
			ItemStyle: {
				padding: '2em 0em'
			},
			IconStyle: {
				marginBottom: '.5em'
			},
			auth: {},
		}
	},
	methods:
	{
		login() {
			this.$refs.notice.show({
				type: "error",
				message: "请先登录"
			})
		},
		torole() {
			uni.$u.route({
				url: "/pagesB/employee/permission/role/index"
			})
		},
		bookingindex() {
			uni.$u.route({
				url: "/pagesC/product/booking/index"
			})
		},
		product() {
			uni.$u.route({
				url: "/pagesC/product/product/index"
			})
		},
		toemployee() {
			uni.$u.route({
				url: "/pagesB/employee/permission/auth/index"
			})

		},
		adminlog()
		{
			if(this.auth.id==1)
			{
				uni.$u.route({
				url: "/pagesB/employee/permission/log/index"
			})
			}else
			{
				
				uni.showToast({
						title: '您没有此权限',
						icon: 'none'
					})
			}
		

		}

	}
}
</script>